package com.bw.base.imageLoader

class ImageOptions {
    private constructor() {}

    var placeImage = 0
    var errorImage = 0
    var skipMemoryCache = false
    var skipDiskCache = false

    constructor(
        _placeImage: Int,
        _errorImage: Int,
        _skipMemoryCache: Boolean,
        _skipDiskCache: Boolean
    ) {
        placeImage = _placeImage
        errorImage = _errorImage
        skipMemoryCache = _skipMemoryCache
        skipDiskCache = _skipDiskCache
    }

    class Builder {
        //占位图
        private var placeImage = 0

        //错误图
        private var errorImage = 0

        //开启内存缓存
        private var skipMemoryCache = false

        //开启磁盘缓存
        private var skipDiskCache = false
        fun setPlaceImage(placeImage: Int): Builder {
            this.placeImage = placeImage
            return this
        }

        fun setErrorImage(errorImage: Int): Builder {
            this.errorImage = errorImage
            return this
        }

        fun setSkipMemoryCache(skipMemoryCache: Boolean): Builder {
            this.skipMemoryCache = skipMemoryCache
            return this
        }

        fun setSkipDiskCache(skipDiskCache: Boolean): Builder {
            this.skipDiskCache = skipDiskCache
            return this
        }

        fun build(): ImageOptions {
            return ImageOptions(placeImage, errorImage, skipMemoryCache, skipDiskCache)
        }
    }
}